/*
 * Name 		: Chang Hyun Park
 * Student ID	: 2007******
 * Major		: Computer Engineering
 * Year			: 3rd Year
 * Subject		: File Management
 * Filename		: linkedlist.c
 */

#include "header.h"

node* init_linkedlist(node* head)
{
	node *temp, *temp2;
	int i=0, ID=0;
	temp = (node*) malloc(sizeof(node));
	//temp->ID = ++ID;
	temp->bufVal = 0;	//initialize buffer value to 0
	temp->reference = 0;//initialize buffer reference to 0

	head = temp;
	temp2 = temp;
	for(i=0;i<buffer_size-1;i++)//buffer_size-1 because already 1 malloc done
	{
		temp = (node*)malloc(sizeof(node));
		//temp->ID = ++ID;
		temp->bufVal = 0;
		temp->reference = 0;

		temp2->next = temp;
		temp2 = temp;
	}	//After buffer_size-1 loops pops out.
	temp2->next = head;	//Make the linked list a circular linked list


	return head;
}
